<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%--
  Created by IntelliJ IDEA.
  User: 85167
  Date: 2017/12/10
  Time: 11:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <c:import url="/WEB-INF/page/header.jsp"/>
</head>
<body>
<div class="col-md-12">
    <form id="cusForm" class="form-horizontal" enctype="multipart/form-data">
        <div class="form-group">
            <div class="file-loading">
                <input id="fileinput" class="file" name="file" type="file">
            </div>
        </div>
    </form>
</div>
<c:import url="/WEB-INF/page/footer.jsp"/>
<script type="text/javascript">
    $("#fileinput").fileinput({
        theme: 'fa',
        language: 'zh',
        maxFileCount: 1,
        uploadUrl: base + '/file/upload',
        allowedFileExtensions: ['jpg', 'png', 'gif']
    });

    $('#fileinput').on('fileuploaded', function (event, data, previewId, index) {
        if(data.response.code!=0){
            //上传文件失败
            swal("上传文件失败！", "系统错误", "error");
            parent.uploadCallBack(111);
        }else{
            parent.uploadCallBack(data.response.data);
            swal("上传文件失成功！","" ,"success");
            var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            setTimeout(parent.layer.close(index), 5000);
        }
    });
</script>
</body>
</html>
